from django.http import HttpResponseRedirect

class AVSMiddleware(object):
    def process_request(self, request):
        if request.session.get('avs_verified', False):
            return None
        path_array = request.get_full_path().split("/")[1:]
        if path_array[0] in ['avs', 'p', 'gw']:
            return None
        nextURL = request.get_full_path()
        return HttpResponseRedirect('/avs/?next='+nextURL)
